package com.mdp.workflow.biz.hi.convert;

import com.mdp.workflow.bus.event.FlowProcinstStatusEvent;
import org.flowable.engine.history.HistoricProcessInstance;
import org.flowable.engine.runtime.ProcessInstance;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

/**
 * 流程实例 Convert
 *
 *@author 唛盟开源9哥
 */
@Mapper
public interface FlowProcinstConvert {

    FlowProcinstConvert INSTANCE = Mappers.getMapper(FlowProcinstConvert.class);



    default FlowProcinstStatusEvent buildProcessInstanceStatusEvent(Object source, HistoricProcessInstance instance, String status) {
        return new FlowProcinstStatusEvent(source).setId(instance.getId()).setStatus(status)
                .setProcessDefinitionKey(instance.getProcessDefinitionKey()).setBusinessKey(instance.getBusinessKey());
    }

    default FlowProcinstStatusEvent buildProcessInstanceStatusEvent(Object source, ProcessInstance instance, String status) {;
        return new FlowProcinstStatusEvent(source).setId(instance.getId()).setStatus(status)
                .setProcessDefinitionKey(instance.getProcessDefinitionKey()).setBusinessKey(instance.getBusinessKey());
    }


}
